//测试-树
//编译：g++ TestTree.cpp ../../*/*/Tree.hpp -o test
#ifndef __TESTTREE__CPP
#define __TESTTREE__CPP

#include<iostream>
#include"../../DataStructure/Tree/Tree.hpp"

using namespace std;
using namespace NgSiuKei;

int main(void) {
    tree_node<char> *treeA = createTree('a', (child_tree_list_node<char> *)nullptr);
    tree_node<char> *treeB = createTree('b', (child_tree_list_node<char> *)nullptr);
    tree_node<char> *treeC = createTree('c', (child_tree_list_node<char> *)nullptr);
    tree_node<char> *treeD = createTree('d', (child_tree_list_node<char> *)nullptr);
    tree_node<char> *treeE = createTree('e', (child_tree_list_node<char> *)nullptr);
    tree_node<char> *treeF = createTree('f', (child_tree_list_node<char> *)nullptr);

    // DFS: a b d e f c
    // BFS: a b c d e f
    insertSubTree(treeB, treeD);
    insertSubTree(treeB, treeE);
    insertSubTree(treeB, treeF);
    insertSubTree(treeA, treeB);
    insertSubTree(treeA, treeC);

    // DFS: a b c d e f
    // BFS: a b c d e f
    // insertSubTree(treeC, treeD);
    // insertSubTree(treeC, treeE);
    // insertSubTree(treeC, treeF);
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);

    // DFS: a b d e c f
    // BFS: a b c d e f
    // insertSubTree(treeB, treeD);
    // insertSubTree(treeB, treeE);
    // insertSubTree(treeC, treeF);
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);

    // DFS: a b d c e f
    // BFS: a b c d e f
    // insertSubTree(treeB, treeD);
    // insertSubTree(treeC, treeE);
    // insertSubTree(treeC, treeF);
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);

    // DFS: a b e c f d
    // BFS: a b c d e f
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);
    // insertSubTree(treeA, treeD);
    // insertSubTree(treeB, treeE);
    // insertSubTree(treeC, treeF);

    // DFS: a b e c d f
    // BFS: a b c d e f
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);
    // insertSubTree(treeA, treeD);
    // insertSubTree(treeB, treeE);
    // insertSubTree(treeD, treeF);

    // DFS: a b c e d f
    // BFS: a b c d e f
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeA, treeC);
    // insertSubTree(treeA, treeD);
    // insertSubTree(treeC, treeE);
    // insertSubTree(treeD, treeF);

    // DFS: a b c d f e
    // BFS: a b c d e f
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeB, treeC);
    // insertSubTree(treeB, treeD);
    // insertSubTree(treeB, treeE);
    // insertSubTree(treeD, treeF);

    // DFS: a b c d e f
    // BFS: a b c d e f
    // insertSubTree(treeA, treeB);
    // insertSubTree(treeB, treeC);
    // insertSubTree(treeB, treeD);
    // insertSubTree(treeB, treeE);
    // insertSubTree(treeE, treeF);

    // DFS: a c d e b f
    // BFS: a c e d b f
    // insertSubTree(treeA, treeC);
    // insertSubTree(treeA, treeE);
    // insertSubTree(treeC, treeD);
    // insertSubTree(treeE, treeB);
    // insertSubTree(treeE, treeF);

    U_L_L num = getTreeNodeNum(treeA);
    U_L_L height = getTreeHeight(treeA);
    cout << "num = " << num << endl;
    cout << "height = " << height << endl;

    char *dfsArray = dfsOrderTree(treeA);
    char *bfsArray = bfsOrderTree(treeA);

    cout << "DFS = [ ";
    for(U_L_L i=0; i<num; ++i) {
        cout << dfsArray[i] << ' ';
    }
    cout << ']' << endl;

    cout << "BFS = [ ";
    for(U_L_L i=0; i<num; ++i) {
        cout << bfsArray[i] << ' ';
    }
    cout << ']' << endl;

    clearTree(treeA);
    delete dfsArray;
    delete bfsArray;
    if(nullptr == treeA) {
        cout << "CNM" << endl;
    }

    return 0;
}

#endif